﻿using System;
using System.Reflection;
using System.Xml;

namespace ProtocolParser.TextParser
{
    public class TextParser : ITextParser
    {
        public string Parse(string formatPath, string contentPath)
        {
            throw new NotImplementedException();
        }

        public object Parse(Type type, string formatPath, string contentPath)
        {
            object obj = Activator.CreateInstance(type);

            using (XmlTextReader reader = new XmlTextReader(contentPath))
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                        case XmlNodeType.Text:
                        case XmlNodeType.XmlDeclaration:
                        case XmlNodeType.ProcessingInstruction:
                        case XmlNodeType.Comment:
                        case XmlNodeType.EndElement:
                        default:
                            break;
                    }
                }
            }

            return obj;
        }

        private void SetObjectProperty(object obj, string propertyName, object value)
        {
            PropertyInfo pinfo = obj.GetType().GetProperty(propertyName);

            pinfo.SetValue(obj, value, null);
        }
    }
}
